package com.javaee.wordtree.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javaee.wordtree.entity.StoryPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
public interface StoryPageMapper extends BaseMapper<StoryPage> {
    
    @Select("SELECT * FROM story_pages WHERE template_id = #{templateId} ORDER BY page_number")
    List<StoryPage> findByTemplateId(@Param("templateId") Long templateId);
    
    @Select("SELECT * FROM story_pages WHERE parent_page_id = #{parentPageId} AND choice_index = #{choiceIndex}")
    StoryPage findByParentAndChoice(@Param("parentPageId") Long parentPageId, @Param("choiceIndex") Integer choiceIndex);
    
    @Select("SELECT * FROM story_pages WHERE template_id = #{templateId} AND page_number = 1")
    StoryPage findFirstPage(@Param("templateId") Long templateId);
}